package testing;

import pt.ist.meic.pava.SyncCommons.Atomic;

public class Bank {
	
	private final Account[] accounts;
	
	
	
	public Bank(int numAccounts, int initial) {
		
		this.accounts = new Account[numAccounts];
		
		for (int i = 0; i < numAccounts; i++) {
			accounts[i] = new Account(initial);
		}
	}
	
	public Account getAccount(int num) {
		
		return accounts[num];
	}
	
	@Atomic
	public void transfer(int from, int to, int amount) {
		accounts[from].withdraw(amount);
		accounts[to].deposit(amount);
	}
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
}
